home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / update / tpasc302.cpt / TCL Update / New ArtClass Files / CAboutBox.p next >
Encoding:
Text File  |  1990-05-11  |  8.4 KB  |  367 lines

  1. {****************************************************}
  2. {         CAboutBox.p}
  3. {}
  4. {        The AboutBox Class}
  5. {}
  6. {        SUPERCLASS = CDirector}
  7. {}
  8. {        Copyright ⌐ 1989, Symantec Corporation.  All rights reserved.            }
  9. {}
  10. {****************************************************}
  11.  
  12. unit CAboutBox;
  13.  
  14. interface
  15.  
  16.     uses
  17.         TCL, MoreTCL, ArtClassIntf;
  18.  
  19.     type
  20.         BytePoint = record
  21.                 h: SignedByte;
  22.                 v: SignedByte;
  23.             end;
  24.  
  25.         BytePointP = ^BytePoint;
  26.         BytePointH = ^BytePointP;
  27.  
  28.  
  29. {** Class Constants **}
  30.  
  31.     const
  32.         WIND_ABOUT = 2000;
  33.         xBytePoints = (maxint div sizeof(BytePoint)) - 1;
  34.  
  35.     type
  36.         BytePointArray = array[0..xBytePoints] of BytePoint;
  37.         BytePointArrayP = ^BytePointArray;
  38.         BytePointArrayH = ^BytePointArrayP;
  39.  
  40.  
  41. implementation
  42.  
  43.  
  44.  
  45. {*** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ***}
  46.  
  47.  
  48.  
  49. {****************************************************}
  50. { IAboutBox}
  51. {}
  52. {        Initialize an AboutBox object}
  53. {}
  54. {****************************************************}
  55.  
  56.     procedure CAboutBox.IAboutBox (aSupervisor: CApplication);
  57.         var
  58.             theWindow: CWindow;     { Altered by TCL Weaver 1.0 (5/9/90) }
  59.  
  60.     begin
  61.         IDirector(aSupervisor);
  62.  
  63.         if ColorQDIsPresent then
  64.             begin
  65.                 new(CColorWindow(theWindow));       { Altered by TCL Weaver 1.0 (5/9/90) }
  66.                 itsWindow := theWindow;
  67.                 CColorWindow(itsWindow).IColorWindow(WIND_ABOUT, TRUE, gDesktop, SELF);
  68.             end
  69.         else
  70.             begin
  71.                 new(theWindow);         { Altered by TCL Weaver 1.0 (5/9/90) }
  72.                 itsWindow := theWindow;
  73.                 itsWindow.IWindow(WIND_ABOUT, TRUE, gDesktop, SELF);
  74.             end;
  75.  
  76.         blackboard := GetPicture(2000);        { Load in resources                }
  77.         flatEraser := GetPicture(2001);
  78.         rightEraser := GetPicture(2002);
  79.         leftEraser := GetPicture(2003);
  80.         wink := GetPicture(2004);
  81.         acHVof := GetResource('HVof', 1);
  82.         ghdHVof := GetResource('HVof', 2);
  83.         gthHVof := GetResource('HVof', 3);
  84.  
  85.         gDecorator.CenterWindow(itsWindow);
  86.  
  87.         Display;
  88.     end;
  89.  
  90.  
  91. {****************************************************}
  92. { Free (OVERRIDE)}
  93. {}
  94. {        Dispose of AboutBox by releasing all its resources}
  95. {}
  96. {****************************************************}
  97.  
  98.     procedure CAboutBox.Free;
  99.     begin
  100.         ReleaseResource(Handle(blackboard));
  101.         ReleaseResource(Handle(flatEraser));
  102.         ReleaseResource(Handle(rightEraser));
  103.         ReleaseResource(Handle(leftEraser));
  104.         ReleaseResource(Handle(wink));
  105.         ReleaseResource(Handle(acHVof));
  106.         ReleaseResource(Handle(ghdHVof));
  107.         ReleaseResource(Handle(gthHVof));
  108.  
  109.         inherited Free;
  110.     end;
  111.  
  112.  
  113. {****************************************************}
  114. { Display}
  115. {}
  116. {        Display contents of About Box. There's a lot of ugly code here and}
  117. {        hard-wired values.}
  118. {}
  119. {****************************************************}
  120.  
  121.     function MouseOrKey (duration: longint): Boolean;
  122.  
  123.             {Kill time for the specified duration, in ticks.                }
  124.             {Exit early if the mouse is clicked or a key is pressed.    }
  125.  
  126.         type
  127.             fourLongs = record
  128.                     one, two, three, four: longint;
  129.                 end;
  130.  
  131.         var
  132.             startTicks: longint;
  133.             macKeyMap: KeyMap;
  134.             allKeys: fourLongs;
  135.  
  136.     begin
  137.         startTicks := TickCount;
  138.  
  139.         while (TickCount - startTicks) < duration do
  140.             begin
  141.                 GetKeys(macKeyMap);
  142.                 macKeyMap[57] := false;            {We want to show the about box     }
  143.                                                 {even if Caps Lock is down.            }
  144.                 macKeyMap[127] := false;            {The Reset key causes trouble for some     }
  145.                                                 {reason.                                        }
  146.                 allKeys := fourLongs(macKeyMap);
  147.                 if Button or (allKeys.one <> 0) or (allKeys.two <> 0) or (allKeys.three <> 0) or (allKeys.four <> 0) then
  148.                     begin
  149.                         MouseOrKey := TRUE;
  150.                         Exit(MouseOrKey);
  151.                     end;
  152.             end;
  153.  
  154.         MouseOrKey := FALSE;
  155.     end;
  156.  
  157.  
  158.     procedure CAboutBox.Display;
  159.         var
  160.             fBlackboard, fFlatEraser, fRightEraser, fLeftEraser, fWink, eraseClip, r, theRect: Rect;
  161.             i: integer;
  162.             n: integer;
  163.             theHVof: Handle;
  164.             off: BytePointArrayH;
  165.             chalkColor: RGBColor;
  166.  
  167.     begin
  168.         itsWindow.Select;
  169.         itsWindow.Prepare;
  170.         SetOrigin(-12, -12);
  171.  
  172.         fBlackboard := blackboard^^.picFrame;
  173.         fFlatEraser := flatEraser^^.picFrame;
  174.         OffsetRect(fFlatEraser, 250, 142);
  175.         fRightEraser := rightEraser^^.picFrame;
  176.         fLeftEraser := leftEraser^^.picFrame;
  177.         fWink := wink^^.picFrame;
  178.         OffsetRect(fWink, 51, 111);
  179.  
  180.         r := theRect;
  181.  
  182.         DrawPicture(blackboard, fBlackboard);
  183.         DrawPicture(flatEraser, fFlatEraser);
  184.         SetRect(eraseClip, 40, 32, 288, 108);
  185.  
  186.         if ColorQDIsPresent then
  187.             begin
  188. {$PUSH}
  189. {$R-}
  190.                 chalkColor.red := 65281;
  191.                 chalkColor.green := 65281;
  192.                 chalkColor.blue := 52225;
  193. {$POP}
  194.                 RGBForeColor(chalkColor);
  195.                 RGBBackColor(chalkColor);
  196.             end
  197.         else
  198.             ForeColor(whiteColor);
  199.  
  200.         while TRUE do
  201.             begin
  202.                 if MouseOrKey(20) then
  203.                     Exit(Display);
  204.  
  205.                 SetRect(r, 80, 40, 82, 42);
  206.                 n := integer(GetHandleSize(acHVof) div sizeof(BytePoint));
  207.                 off := BytePointArrayH(acHVof);
  208.  
  209.                 for i := 0 to n - 1 do
  210.                     begin
  211.                         OffsetRect(r, off^^[i].h, off^^[i].v);
  212.                         PaintRect(r);
  213.                         if MouseOrKey(2) then
  214.                             Exit(Display);
  215.                     end;
  216.  
  217.  
  218.                 if MouseOrKey(60) then
  219.                     Exit(Display);
  220.                 ClipRect(fFlatEraser);
  221.                 DrawPicture(blackboard, fBlackboard);
  222.                 if MouseOrKey(30) then
  223.                     Exit(Display);
  224.  
  225.                 ClipRect(fBlackboard);
  226.                 OffsetRect(fRightEraser, 60 - fRightEraser.left, 12 - fRightEraser.top);
  227.                 DrawPicture(rightEraser, fRightEraser);
  228.  
  229.                 for i := 0 to 64 do
  230.                     begin
  231.                         OffsetRect(fRightEraser, 3, 1);
  232.                         DrawPicture(rightEraser, fRightEraser);
  233.                         if MouseOrKey(1) then
  234.                             Exit(Display);
  235.                     end;
  236.  
  237.                 for i := 0 to 8 do
  238.                     begin
  239.                         OffsetRect(fRightEraser, 0, 3);
  240.                         DrawPicture(rightEraser, fRightEraser);
  241.                         if MouseOrKey(1) then
  242.                             Exit(Display);
  243.                     end;
  244.  
  245.                 fLeftEraser := fRightEraser;
  246.                 DrawPicture(leftEraser, fLeftEraser);
  247.                 for i := 0 to 64 do
  248.                     begin
  249.                         OffsetRect(fLeftEraser, -3, -1);
  250.                         DrawPicture(leftEraser, fLeftEraser);
  251.                         if MouseOrKey(1) then
  252.                             Exit(Display);
  253.                     end;
  254.  
  255.                 ClipRect(fLeftEraser);
  256.                 DrawPicture(blackboard, fBlackboard);
  257.                 if MouseOrKey(30) then
  258.                     Exit(Display);
  259.                 ClipRect(fBlackboard);
  260.                 DrawPicture(flatEraser, fFlatEraser);
  261.                 if MouseOrKey(30) then
  262.                     Exit(Display);
  263.  
  264.                 n := integer(GetHandleSize(ghdHVof) div sizeof(BytePoint));
  265.                 off := BytePointArrayH(ghdHVof);
  266.  
  267.                 SetRect(r, 90, 35, 92, 37);
  268.                 for i := 0 to n - 1 do
  269.                     begin
  270.                         OffsetRect(r, off^^[i].h, off^^[i].v);
  271.                         PaintRect(r);
  272.                         if MouseOrKey(2) then
  273.                             Exit(Display);
  274.                     end;
  275.  
  276.                 if MouseOrKey(60) then
  277.                     Exit(Display);
  278.                 ClipRect(fFlatEraser);
  279.                 DrawPicture(blackboard, fBlackboard);
  280.                 if MouseOrKey(30) then
  281.                     Exit(Display);
  282.  
  283.                 ClipRect(fBlackboard);
  284.                 OffsetRect(fRightEraser, 70 - fRightEraser.left, 12 - fRightEraser.top);
  285.                 DrawPicture(rightEraser, fRightEraser);
  286.  
  287.                 for i := 0 to 64 do
  288.                     begin
  289.                         OffsetRect(fRightEraser, 3, 1);
  290.                         DrawPicture(rightEraser, fRightEraser);
  291.                         if MouseOrKey(1) then
  292.                             Exit(Display);
  293.                     end;
  294.  
  295.                 for i := 0 to 8 do
  296.                     begin
  297.                         OffsetRect(fRightEraser, 0, 3);
  298.                         DrawPicture(rightEraser, fRightEraser);
  299.                         if MouseOrKey(1) then
  300.                             Exit(Display);
  301.                     end;
  302.  
  303.                 fLeftEraser := fRightEraser;
  304.                 DrawPicture(leftEraser, fLeftEraser);
  305.                 for i := 0 to 64 do
  306.                     begin
  307.                         OffsetRect(fLeftEraser, -3, -1);
  308.                         DrawPicture(leftEraser, fLeftEraser);
  309.                         if MouseOrKey(1) then
  310.                             Exit(Display);
  311.                     end;
  312.  
  313.                 fRightEraser := fLeftEraser;
  314.                 DrawPicture(rightEraser, fRightEraser);
  315.                 for i := 0 to 8 do
  316.                     begin
  317.                         OffsetRect(fRightEraser, 0, 3);
  318.                         DrawPicture(rightEraser, fRightEraser);
  319.                         if MouseOrKey(1) then
  320.                             Exit(Display);
  321.                     end;
  322.  
  323.                 for i := 0 to 25 do
  324.                     begin
  325.                         OffsetRect(fRightEraser, 3, 1);
  326.                         DrawPicture(rightEraser, fRightEraser);
  327.                         if MouseOrKey(1) then
  328.                             Exit(Display);
  329.                     end;
  330.  
  331.                 ClipRect(fRightEraser);
  332.                 DrawPicture(blackboard, fBlackboard);
  333.                 if MouseOrKey(30) then
  334.                     Exit(Display);
  335.                 ClipRect(fBlackboard);
  336.                 DrawPicture(flatEraser, fFlatEraser);
  337.                 if MouseOrKey(30) then
  338.                     Exit(Display);
  339.  
  340.                 n := integer(GetHandleSize(gthHVof) div sizeof(BytePoint));
  341.                 off := BytePointArrayH(gthHVof);
  342.  
  343.                 SetRect(r, 45, 35, 47, 37);
  344.                 for i := 0 to n - 1 do
  345.                     begin
  346.                         OffsetRect(r, off^^[i].h, off^^[i].v);
  347.                         PaintRect(r);
  348.                         if MouseOrKey(2) then
  349.                             Exit(Display);
  350.                     end;
  351.  
  352.                 if MouseOrKey(40) then
  353.                     Exit(Display);
  354.                 ClipRect(fWink);
  355.                 DrawPicture(wink, fWink);
  356.                 if MouseOrKey(20) then
  357.                     Exit(Display);
  358.                 DrawPicture(blackboard, fBlackboard);
  359.                 if MouseOrKey(150) then
  360.                     Exit(Display);
  361.                 ClipRect(eraseClip);
  362.                 DrawPicture(blackboard, fBlackboard);
  363.             end;
  364.     end;
  365.  
  366.  
  367. end.